import 'package:fish_redux/fish_redux.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/company_component/component.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/company_component/state.dart';

import 'effect.dart';
import 'reducer.dart';
import 'state.dart';
import 'view.dart';

class VillageSimpleComponent extends Component<VillageSimpleState> {
  VillageSimpleComponent()
      : super(
          effect: buildEffect(),
          reducer: buildReducer(),
          view: buildView,
          dependencies: Dependencies<VillageSimpleState>(
              adapter: null,
              slots: <String, Dependent<VillageSimpleState>>{
                'house-info': _HouseConnector() + CompanyComponent(),
              }),
        );
}

class _HouseConnector extends ConnOp<VillageSimpleState, CompanyState> {
  var _companyState = CompanyState();
  @override
  CompanyState get(VillageSimpleState state) {
    _companyState.build = state.build;
    _companyState.unit = state.unit;
    _companyState.house = state.house;
    return _companyState;
  }

  @override
  void set(VillageSimpleState state, CompanyState subState) {
    _companyState = subState;
  }
}
